package server

import "gitee.com/crack007/goose/gsjob"

type ClientJob struct {
	idleTimeout IIdleTimeout
	*gsjob.Job
}

func (x *ClientJob) Run() {
	if x.idleTimeout != nil && x.idleTimeout.IsTimeout() {
		x.idleTimeout.OnTimeout()
	}
}

func NewClientJob(idleTimeout IIdleTimeout, jobName string, scheduleConfig *gsjob.ScheduleConfig) *ClientJob {
	clientJob := &ClientJob{
		idleTimeout: idleTimeout,
	}
	clientJob.Job = gsjob.NewJob(jobName, scheduleConfig, clientJob)
	return clientJob
}
